import {observable, action} from 'mobx'
import * as API_LIST from '../../apis/customReport/customReport'
import * as FnaMessage from '../../public/FnaMessage'
import { WeaLocaleProvider } from 'ecCom';
import {ConstantStatus,Permission} from '../../public/FnaConstant'
import {WeaTableNew} from 'comsMobx'
const {TableStore} = WeaTableNew
const getLabel = WeaLocaleProvider.getLabel;

/**
 * 展示报表页面Store   暂时先用一个
 */
export class ShowReportStore {

	constructor(){
	}

    @observable loading = false;

    @observable hasRight;//权限的标记 4无权限，跳转

	//展示自定义报表
	@observable dataKey = "";
    @observable tableStore = new TableStore();

    //列表数据
    initDatas = (value) => {
        this.getShowList(value,false);
	}
	
    //获取报表数据
    getShowList = (value = {},flag = true) => {
        this.loading = true;
        API_LIST.getShowList(value).then( data => {
            let {status} = data;
            if(status == ConstantStatus.FNA_RESULT_SUCCESS){
                this.hasRight = Permission.FNA_HASRIGHT;
                
                if(flag){//回到第一页
                    this.tableStore.getDatas(data.datas,1);
                }else{
                    this.tableStore.getDatas(data.datas);
                }
                this.dataKey = data.datas;
            } else if(status == ConstantStatus.FNA_RESULT_HAS_NO_RIGHT){//没有权限
                this.hasRight = Permission.FNA_NORIGHT;
            }    
            this.loading = false;
        });
	}
}